package mapReduce.demo06_sort.demo01_yearTemp;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class YearTempPartitioner extends Partitioner<Text,Text> {
    @Override
    public int getPartition(Text text, Text text2, int numPartitions) {

        int year = Integer.parseInt(text.toString());

        if(year>=1900 && year<=1930){
            return 0;
        }else if(year>1930 && year<=1960){
            return 1;
        }else if(year>1960 && year<=1990){
            return 2;
        }else if(year>1990 && year<=2020){
            return 3;
        }else{
            return 0;
        }
    }
}
